import React from "react";
import { Table, Switch, message } from 'antd';
import { timeToStr } from '../../../../../utils/time'
import api from "../../../../../api";


const OrderTable = (props: any) => {
    const columns = [
        {
            title: '序号',
            dataIndex: 'number',
            key: 'number',
        },
        {
            title: '编号',
            dataIndex: 'id',
            key: 'id',
        },
        {
            title: '用户名',
            dataIndex: 'name',
            key: 'name',
        },
        {
            title: '手机号',
            dataIndex: 'tel',
            key: 'tel',
        },
        {
            title: '类型',
            dataIndex: 'type',
            key: 'type',
        },
        {
            title: '支付金额',
            dataIndex: 'money',
            key: 'money',
        },
        {
            title: '支付时间',
            dataIndex: 'pay_time',
            key: 'pay_time',
            render: (time: any) => {
                return <span>{timeToStr(time)}</span>
            }
        },
        {
            title: '操作',
            key: "option",
            render: (text: any, item: any) => {
                return <div className="option-house">
                    <span onClick={() => { del(item.id) }}>删除</span>
                </div>
            }
        },
    ];
    // 方法
    // 点击删除
    const del = (id: string) => {
        // 把id传递给父组件的删除方法
        props.delOrder(id)
    }
    return (
        <>
            {props.dataSource[0] && <Table dataSource={props.dataSource} columns={columns} rowKey={record => record.id}
                pagination={false}
            />}
        </>

    )
};

export default OrderTable